<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: kane <chengjin005@163.com> 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\wsapi\controller;

use app\wsapi\controller\BaseController;
use think\Db;

/**
 * Class 
 * @package app\admin\controller
 */
class CustomerController extends BaseController
{
	/**
	 * 用户个人中心
	 */
	public function info()
	{
		$userid = $this->request->param('userid');
		$result = Db::name('customer')
								->field('cmf_customer.*,cmf_company.company_name,cmf_company.company_mail_address')
								->join('cmf_company','cmf_company.id = cmf_customer.company_id','left')
								->where(['cmf_customer.id'=>$userid])
								->find();
		ajaxReturn(['status'=>1,'msg'=>'获取成功','data'=>$result]);
	}

	/**
	 * 用户编辑
	 */
	public function edit()
	{
		$userid = $this->request->param('userid');
		$data   = $this->request->param();
		$result['customer_email'] = $data['customer_email'];
		$result['update_time']    = time();
		Db::name('customer')->where(['id'=>$userid])->update($result);
		ajaxReturn(['status'=>1,'msg'=>'修改成功']);
	}

}